package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.TravelOrderPaymentRecord;
import com.ktgj.customer.service.ITravelOrderPaymentRecordService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 支付记录Controller
 * 
 * @author ruoyi
 * @date 2022-11-14
 */
@RestController
@RequestMapping("/travelRecord")
public class TravelOrderPaymentRecordController extends BaseController
{
    @Autowired
    private ITravelOrderPaymentRecordService travelOrderPaymentRecordService;

    /**
     * 查询支付记录列表
     */
    @PreAuthorize(hasPermi = "customer:record:list")
    @GetMapping("/list")
    public TableDataInfo list(TravelOrderPaymentRecord travelOrderPaymentRecord)
    {
        startPage();
        List<TravelOrderPaymentRecord> list = travelOrderPaymentRecordService.selectTravelOrderPaymentRecordList(travelOrderPaymentRecord);
        return getDataTable(list);
    }

    /**
     * 导出支付记录列表
     */
    @PreAuthorize(hasPermi = "customer:record:export")
    @Log(title = "支付记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TravelOrderPaymentRecord travelOrderPaymentRecord) throws IOException
    {
        List<TravelOrderPaymentRecord> list = travelOrderPaymentRecordService.selectTravelOrderPaymentRecordList(travelOrderPaymentRecord);
        ExcelUtil<TravelOrderPaymentRecord> util = new ExcelUtil<TravelOrderPaymentRecord>(TravelOrderPaymentRecord.class);
        util.exportExcel(response, list, "支付记录数据");
    }

    /**
     * 获取支付记录详细信息
     */
    @PreAuthorize(hasPermi = "customer:record:query")
    @GetMapping(value = "/{payId}")
    public AjaxResult getInfo(@PathVariable("payId") Long payId)
    {
        return AjaxResult.success(travelOrderPaymentRecordService.selectTravelOrderPaymentRecordById(payId));
    }

    /**
     * 新增支付记录
     */
    @PreAuthorize(hasPermi = "customer:record:add")
    @Log(title = "支付记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TravelOrderPaymentRecord travelOrderPaymentRecord)
    {
        return toAjax(travelOrderPaymentRecordService.insertTravelOrderPaymentRecord(travelOrderPaymentRecord));
    }

    /**
     * 修改支付记录
     */
    @PreAuthorize(hasPermi = "customer:record:edit")
    @Log(title = "支付记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelOrderPaymentRecord travelOrderPaymentRecord)
    {
        return toAjax(travelOrderPaymentRecordService.updateTravelOrderPaymentRecord(travelOrderPaymentRecord));
    }

    /**
     * 删除支付记录
     */
    @PreAuthorize(hasPermi = "customer:record:remove")
    @Log(title = "支付记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{payIds}")
    public AjaxResult remove(@PathVariable Long[] payIds)
    {
        return toAjax(travelOrderPaymentRecordService.deleteTravelOrderPaymentRecordByIds(payIds));
    }
}
